
package com.leaves.sys.modular.timer.controller;

import com.leaves.core.annotion.BusinessLog;
import com.leaves.core.annotion.Permission;
import com.leaves.core.enums.LogAnnotionOpTypeEnum;
import com.leaves.core.pojo.response.ResponseData;
import com.leaves.core.pojo.response.SuccessResponseData;
import com.leaves.sys.modular.timer.param.SysTimersLogParam;
import com.leaves.sys.modular.timer.service.SysTimersLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 定时任务日志控制器
 *
 * @author 寻叶人
 * @date 2021-12-09 16:01:27
 */
@RestController
@Api(tags = "定时任务日志")
public class SysTimersLogController {

    @Resource
    private SysTimersLogService sysTimersLogService;

    /**
     * 查询定时任务日志
     *
     * @author 寻叶人
     * @date 2021-12-09 16:01:27
     */
    @Permission
    @GetMapping("/sysTimersLog/page")
    @BusinessLog(title = "定时任务日志_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation(value = "查询定时任务日志分页")
    public ResponseData page(SysTimersLogParam sysTimersLogParam) {
        return new SuccessResponseData(sysTimersLogService.page(sysTimersLogParam));
    }

    /**
     * 添加定时任务日志
     *
     * @author 寻叶人
     * @date 2021-12-09 16:01:27
     */
    @Permission
    @PostMapping("/sysTimersLog/add")
    @BusinessLog(title = "定时任务日志_增加", opType = LogAnnotionOpTypeEnum.ADD)
    @ApiOperation(value = "添加定时任务日志")
    public ResponseData add(@RequestBody @Validated(SysTimersLogParam.add.class) SysTimersLogParam sysTimersLogParam) {
            sysTimersLogService.add(sysTimersLogParam);
        return new SuccessResponseData();
    }

    /**
     * 删除定时任务日志，可批量删除
     *
     * @author 寻叶人
     * @date 2021-12-09 16:01:27
     */
    @Permission
    @PostMapping("/sysTimersLog/delete")
    @BusinessLog(title = "定时任务日志_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    @ApiOperation(value = "删除定时任务日志")
    public ResponseData delete(@RequestBody @Validated(SysTimersLogParam.delete.class) List<SysTimersLogParam> sysTimersLogParamList) {
            sysTimersLogService.delete(sysTimersLogParamList);
        return new SuccessResponseData();
    }

    /**
     * 编辑定时任务日志
     *
     * @author 寻叶人
     * @date 2021-12-09 16:01:27
     */
    @Permission
    @PostMapping("/sysTimersLog/edit")
    @BusinessLog(title = "定时任务日志_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    @ApiOperation(value = "编辑定时任务日志")
    public ResponseData edit(@RequestBody @Validated(SysTimersLogParam.edit.class) SysTimersLogParam sysTimersLogParam) {
            sysTimersLogService.edit(sysTimersLogParam);
        return new SuccessResponseData();
    }

    /**
     * 查看定时任务日志
     *
     * @author 寻叶人
     * @date 2021-12-09 16:01:27
     */
    @Permission
    @GetMapping("/sysTimersLog/detail")
    @BusinessLog(title = "定时任务日志_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    @ApiOperation(value = "查看定时任务日志")
    public ResponseData detail(@Validated(SysTimersLogParam.detail.class) SysTimersLogParam sysTimersLogParam) {
        return new SuccessResponseData(sysTimersLogService.detail(sysTimersLogParam));
    }

    /**
     * 定时任务日志列表
     *
     * @author 寻叶人
     * @date 2021-12-09 16:01:27
     */
    @Permission
    @GetMapping("/sysTimersLog/list")
    @BusinessLog(title = "定时任务日志_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation(value = "定时任务日志列表")
    public ResponseData list(SysTimersLogParam sysTimersLogParam) {
        return new SuccessResponseData(sysTimersLogService.list(sysTimersLogParam));
    }

    /**
     * 导出系统用户
     *
     * @author 寻叶人
     * @date 2021-12-09 16:01:27
     */
    @Permission
    @GetMapping("/sysTimersLog/export")
    @BusinessLog(title = "定时任务日志_导出", opType = LogAnnotionOpTypeEnum.EXPORT)
    @ApiOperation(value = "导出定时任务日志列表")
    public void export(SysTimersLogParam sysTimersLogParam) {
        sysTimersLogService.export(sysTimersLogParam);
    }
    /**
     * 清空日志
     *
     * @author 寻叶人
     * @date 2021-12-09 16:01:27
     */
    @Permission
    @PostMapping("/sysTimersLog/deleteAll")
    @BusinessLog(title = "清空日志", opType = LogAnnotionOpTypeEnum.DELETE)
    @ApiOperation(value = "清空日志")
    public void deleteAll() {
        sysTimersLogService.deleteAll();
    }
}
